package utils

import (
	"awesomeProject/zinx/ziface"
	"encoding/json"
	"io/ioutil"
)

type GlobalObj struct {
	TcpServer      ziface.IServer
	Host           string
	TcpPort        int
	Name           string
	Version        string
	MaxConn        int
	MaxPackageSize uint32
	WorkerPoolSize uint32
	MaxWorkerTaskLen uint32
}

var GlobalObject *GlobalObj

func (g *GlobalObj) Reload() {
	data, err := ioutil.ReadFile("zinx.json")
	if err != nil {
		panic(err)
	}
	err = json.Unmarshal(data, &GlobalObject)
	if err != nil {
		panic(err)
	}
}

func init() {
	GlobalObject = &GlobalObj{
		Host:           "0.0.0.0",
		TcpPort:        8999,
		Name:           "ZinxServerApp",
		Version:        "v0.4",
		MaxConn:        1000,
		MaxPackageSize: 4096,
		WorkerPoolSize: 2,
		MaxWorkerTaskLen: 1024,
	}
	//GlobalObject.Reload()
}
